import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { reqHospitalDetail, reqHospitalDeparment } from '@/api/hospitalsInfo'
import { type hospitalDetail, type HosPitalDataDetail } from '@/api/type.ts'

export const useHosMsgStore = defineStore('hospitalMsg', () => {
  // const count = ref(0)
  // const doubleCount = computed(() => count.value * 2)
  // function increment() {
  //   count.value++
  // }

  const hospitalMsg = ref({} as HosPitalDataDetail)
  const DepartmentMsg = ref({})
  async function gethospitalMsg(hoscode: string) {
    const res: hospitalDetail = await reqHospitalDetail(hoscode)
    // console.log('获取医院信息', res)
    hospitalMsg.value = res.data
  }
  async function getDepartmentMsg(hoscode: string) {
    const res2 = await reqHospitalDeparment(hoscode)
    // console.log('获取科室信息', res2.data)
    DepartmentMsg.value = res2.data
  }


  return { hospitalMsg, DepartmentMsg, gethospitalMsg, getDepartmentMsg }
})
